﻿<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8" />
    <script type="text/javascript" src="../../Content/highlighter/scripts/shCore.js"></script>
    <script type="text/javascript" src="../../Content/highlighter/scripts/shBrushCSharp.js"></script>
    <script type="text/javascript" src="../../Content/highlighter/scripts/shBrushXml.js"></script>
    <link type="text/css" rel="stylesheet" href="../../Content/highlighter/styles/shCoreDefault.css" />
    <script type="text/javascript">SyntaxHighlighter.all();</script>
    <title></title>
</head>
<body>
    <pre class="xml">
        &lt;script type="text/javascript">
            $("#myTable").bootstrapTable({
                url: "brand/getlist",
                method: "post",
                toolbar: "#toolbar",
                striped: true,
                cache: false,
                pagination: true,
                sortable: true,
                sortOrder: 'desc',
                sortName: 'Id',
                queryParams: function (params) {
                    var temp = { //这里的键的名字和控制器的变量名必须一直，这边改动，控制器也需要改成一样的
                        limit: params.limit, //页面大小
                        offset: params.offset, //页码
                        name: $("#txtSearchKey").val(),
                        status: $("#Status").val(),
                        sort: params.sort,
                        order: params.order
                    };
                    return temp;
                },
                sidePagination: "server",
                pageNumber: 1,
                pageSize: 10,
                pageList: [10, 25, 50, 100],
                search: false,
                strictSearch: true,
                showColumns: true,
                showRefresh: true,
                minimumCountColumns: 2,
                clickToSelect: true,
                height: 'auto',
                uniqueId: 'Id',
                showToggle: true,
                cardView: false,
                detailView: false,
                showExport: true,
                exportDataType: "all",
                columns: [
                    {
                        checkbox: true
                    },
                    {
                        field: 'Id',
                        title: '编号',
                        sortable: true
                    }, {
                        field: 'Name',
                        title: '品牌名称',
                        sortable: true
                    }, {
                        field: 'IsRecommend',
                        title: '是否推荐',
                        sortable: true,
                        formatter: function (value) {
                            if (value === 1) {
                                return "启用";
                            } else {
                                return "禁用";
                            }
                        }
                    }, {
                        field: 'Status',
                        title: '状态',
                        sortable: true,
                        formatter: function (value) {
                            if (value === 1) {
                                return "是";
                            } else {
                                return "否";
                            }
                        }
                    }, {
                        field: 'Seq',
                        title: '排序',
                        sortable: true
                    }
                ]
            });
         &lt;/script>
    </pre>
    <pre>
        <script>
            $("#btn_add").click(function () {
                var dialog = layer.open({
                    type: 2,
                    title: '添加品牌',
                    content: '/brand/ShowAdd',
                    anim: 0,
                    maxHeight: 600,
                    end: function () {
                        $("#myTable").bootstrapTable("refresh");
                    }
                });
                layer.style(dialog,
                    {
                        width: "800px",
                        height: "600px"
                    });
            });
            $("#btn_edit").click(function () {
                var selections = $("#myTable").bootstrapTable("getSelections");
                if (selections.length !== 1) {
                    layer.msg("请选择一行");
                    return;
                }
                var dialog = layer.open({
                    type: 2,
                    title: '添加品牌',
                    content: '/brand/ShowModify?brandId=' + selections[0].Id,
                    anim: 0,
                    maxHeight: 600,
                    end: function () {
                        $("#myTable").bootstrapTable("refresh");
                    }
                });
                layer.style(dialog,
                    {
                        width: "800px",
                        height: "600px"
                    });
            });
            $("#btn_delete").click(function () {
                var selections = $("#myTable").bootstrapTable("getSelections");
                if (selections.length !== 1) {
                    layer.msg("请选择一行");
                    return;
                }
                layer.confirm("是否删除选中行？", function (index) {
                    $.post("/brand/delete", { id: selections[0].Id }, function (data) {
                        if (data.Success) {
                            layer.msg(data.Message);
                        } else {
                            layer.msg(data.Message);
                        }
                        layer.close(index);
                        $("#myTable").bootstrapTable("refresh");
                    });
                });
            });
        </script>
    </pre>
</body>
</html>